Allow CID functions to work with non-default multibase.#9
Allow CID functions to work with non-default multibase.#9
Conversation
|
What about passing in formatting options. That is, turn this into: func FromCid(c cid.Cid, options ...CidFormatOption)(or something like that) Yes, it'll probably be slightly more complicated but its extensible and nicer for the user. I can then, e.g., write |
|
Basically, forcing users to pass a CID "transformer" in on every call to |
|
In my view this is not the place for complicated option parsing as that should be done higher up. The idea is we set a single value in the context (using Part of the reason I took in a simple function (rather than say an interface) is to avoid a circular decency with |
|
Or to put it another way the idea is to use the |
This:
FromCidfunction to take a function which translates a Cid to s string.Yes, (1) is an API change but I greatly prefer it to creating another another tediously named function. This function is not used in many places within
go-ipfs. In almost all cases we should be passing in a transformer function anyway, and when we don't have onenilcan be used instead. The general idea is we should eventually get the transformer function from the current context which is nearly always available whenFromCidis used. A function is used instead of just a multibase encoding for added flexibility, for example we may want to upgrade CidV0 to CidV1.CC @Stebalien